import { ApiCall } from "tsrpc";
import { ReqSkillMore, ResSkillMore } from "../../../shared/master/body/PtlSkillMore";
import { player } from "../../../model/fight/body/player";
import {  Tpl_skillInfo, template } from "../../../shared/master/MsgAction";
import { SK_type } from "../../../shared/interface";

export default async function (call: ApiCall<ReqSkillMore, ResSkillMore>) {
    call.succ({})
    let user = call.req._player as player;
    let sks =  user.getAllSkills()
    let sk = sks[call.req.idx - 1];
    if(call.req.idx != 0){
        if(!sk){
            user.sendMsg(template.default,`你自身没有ID为[${call.req.idx + 1}]的技能`)
            return;
        }
    }else{
        let _idx = sks.findIndex((item)=>{
            return item.rename == call.req.name;
        })
        if(_idx == -1){
            user.sendMsg(template.default,`你自身没有ID为[${call.req.idx + 1}]的技能`)
            return;
        }
        sk = sks[_idx];
    }
 
    let tpl:Tpl_skillInfo = sk.get_panel()
    user.sendMsg(template.skill_info,tpl)
}